import 'package:app_base_page/app_base_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'login_bloc.dart';

/**
 *
 * @ProjectName:    login_model
 * @ClassName:      login_page
 * @Description:    dart类作用描述
 * @Author:         孙浩
 * @QQ:             243280864
 * @CreateDate:     2021/1/8 5:53 PM
 */
class LoginPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() => _State();
}
class _State extends BaseState{
  LoginBloc _bloc;
  GlobalKey<FormState> _formKey = GlobalKey();

  @override
  void initState() {
    super.initState(
    );
    _bloc = LoginBloc();
  }

  @override
  Widget initChild(BuildContext c) {
    return Scaffold(body: Form(key: _formKey,child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        TextFormField(decoration: InputDecoration(hintText: "请输入手机号"),onSaved: (String name){
          _bloc.saveName(name);
        },),
        TextFormField(decoration: InputDecoration(hintText: "请输入密码"),onSaved: (String pwd){
          _bloc.savePwd(pwd);
        },),
        MaterialButton(onPressed: () async {
          _formKey.currentState.save();
          await _bloc.loginByPassWord();
          Navigator.pop(context);
        },child: Text("登录"),)
      ],
    )),)  ;
  }
}